#ifndef PERSONALWIDGET_H
#define PERSONALWIDGET_H

#include <QWidget>
#include<QHash>
#include"onevideoinfo.h"
#include"collectitem.h"
#include"createcollect.h"
#include<QListWidgetItem>
#include"privateinfo.h"
#include"firstcollectvideo.h"
#include"databasemanage.h"
#include<QHBoxLayout>
#include"addmyvideo.h"
namespace Ui {
class personalwidget;
}

class personalwidget : public QWidget
{
    Q_OBJECT

public:
    explicit personalwidget(QWidget *parent = nullptr);
    ~personalwidget();
public:
    void setcurindex(int index);
    QHash<QString,QVector<onevideoinfo*>> collects;  //collectname - QVector<videoitem>(每个文件夹名称和其内存放视频信息的映射)  通过数据库处理得到
    QHash<int,QString>  collectsrownum;  // listwidgetindex  -  collectname
    QHash<QString,firstcollectvideo*> collectfirstvideo;  //collectname - firstwidget
    QHash<QPair<int,int>,onevideoinfo*> mycollectvideos;  //存放我收藏的视频    {row,col},onevideoinfo*
    void initcollects(QHash<QString,QVector<onevideoinfo*>> collects,QHash<QString,firstcollectvideo*> collectfirstvideo);
public:
    createcollect* creco;   //用户要创建收藏夹的界面
    addmyvideo* amv;  //添加一个我的视频
    privateinfo* pri;       //访问用户的基本信息
    databasemanage* db;     //访问数据库的指针
    QHash<QString,collectitem*> collectlistitems; // collectname -    collectitem
    bool firstexist=false;
    QVector<onevideoinfo*>  prevones;   //存放上一个收藏的视频内容，用于在转变收藏夹时让layout清楚子元素
    int myvideonextrow=0;  //下一个我的视频在界面中的行数
    int myvideonextcol=0;  //下一个我的视频在界面中的列数
    QHash<QPair<int,int>,onevideoinfo*> myvideos;  //存放我的视频  {row,col},onevideoinfo*
public:
    void connectsignals();
    void init();
    void initprivateinfo(privateinfo* pri);
    void initdatabase(databasemanage* db);
    void initmyvideo(QVector<onevideoinfo*> onevideos);
    void addonevideotocollect(QString collectname,onevideoinfo* oneinfo); //增加一条视频到指定收藏夹中
    void renewcollectcontent(QVector<onevideoinfo*> ones);
signals:
    void enterdetailedvideo(onevideoinfo* one);
    void addonecollectitem(collectitem* co);
private slots:
    void on_mainwidgetbtn_clicked();
    void on_collectbtn_clicked();
    void on_createcollect_clicked();

    void on_collectlist_currentRowChanged(int currentRow);


    void on_addvideobtn_clicked();

    void on_myvideo_cellClicked(int row, int column);

    void on_ct_cellClicked(int row, int column);

private:
    Ui::personalwidget *ui;
};

#endif // PERSONALWIDGET_H
